/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package posicion;

/**
 *
 * @author martin
 */

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.*;


public class HibernateUtils {

    private static final Session mySession;
    private static final SessionFactory sessionFactory;

    static
    {
        try
        {
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
            mySession = sessionFactory.openSession();
        } catch (HibernateException he)
        {
           System.err.println("Ocurrió un error en la inicialización de la SessionFactory: " + he);
            throw new ExceptionInInitializerError(he);
        }
    }

    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }

    public static Session getMySession() {
        return mySession;

    }




}